package com.example.oauth2.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;

/**
 * @ClassName JiuBoDouUserDetails
 * @Description
 * @Author huyingliang
 * @Date 2024-03-05 10:53
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class JiuBoDouUserDetails implements UserDetails {

    private String username;/*应该说是 用户的唯一标识 可以是登录时候用的手机号 也可以是id*/

    private String password;/*这里的密码是数据库中查出来的 加密之后的密码 不是明文*/

    private Collection<? extends GrantedAuthority> authorities;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public String getUsername() {
        return  username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return  true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return  true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
